package cn.rocksolid.sport.assist.config;

import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import cn.rocksolid.sport.common.Constant.OssPt;
import cn.rocksolid.sport.common.error.RSE;
import cn.rocksolid.sport.common.error.RockSolidException;

@ConfigurationProperties(prefix = "rocksolid")
@Component
public class OssConfig {

  private Map<OssPt, Map<String, Map<String, String>>> ossConfigs;

  public Map<OssPt, Map<String, Map<String, String>>> getOssConfigs() {
    return ossConfigs;
  }

  public void setOssConfigs(Map<OssPt, Map<String, Map<String, String>>> ossConfigs) {
    if (MapUtils.isNotEmpty(ossConfigs)) {
      for (Map.Entry<OssPt, Map<String, Map<String, String>>> configEntry : ossConfigs.entrySet()) {
        if (!configEntry.getValue().containsKey(ConfigConst.DEFAULT_CONF)) {
          throw new RockSolidException(RSE.MISS_OSSP_DC);
        }
      }
    }
    this.ossConfigs = ossConfigs;
  }
}
